<include file="../Public/header" />
<link href="{:APPS_URL}/w3g/_static/style.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="__THEME__/js/loadImage/js/jquery.LoadImage.js?v=1235"></script>
<link rel="stylesheet" href="__APP__/swiper/dist/idangerous.swiper.css">
<script src="__APP__/swiper/dist/idangerous.swiper.min.js"></script>
<script type="text/javascript" src="__THEME__/js/module.weibo.js"></script> 
<script type="text/javascript">					
$(function(){
	var loading_pic = "__THEME__/js/loadImage/loading.gif";
	var target_id = "content_img_list";

	var width = $("#detail_content_img").width()-20;	
	$("#detail_content_img img").LoadImage(true,width,width,loading_pic, target_id);
	
	$(".reply_content_img").each(function() {
		var width = $(this).width()-20;	
        $(this).find('img').LoadImage(true,width,width,loading_pic, target_id);
    });
	

  
});
var mySwiper
function showBigImgBox(obj){
	console.log(123);
	$('.pagination').html('');
	$('.swiper-slide-duplicate').remove('');
	$('#content_img_list').html("");
	
	var old_src = $(obj).attr('src');
		
	var imgArr = new Array();
	var index = 0;
	
	$(obj).closest('.content_imgs').find('img').each(function(i, e) {
		var src = $(this).attr('src');

		if(src!=""){
			imgArr.push(src);
			var html = "<div class=\"swiper-slide\"><img src=\""+src+"\" width=\"100%\" /></div>";
			$('#content_img_list').append(html);
			if(src==old_src){
				index = i;
			}
		}        
    });

	$('.device').show();

	mySwiper = new Swiper('.swiper-container',{
		pagination: '.pagination',
		loop:true,
		grabCursor: true,
		paginationClickable: true,
		calculateHeight: true,
		initialSlide:index
    })	
	//location.hash="anchor";
	$("body,html").animate({scrollTop: 0}, 0); 
}
function closeBox(){
	mySwiper.destroy();
	$('.device').hide();
}
</script>

<!-- <a name="anchor"></a> -->
<div id="content">
    <div id="weiba" data-title="{$groupinfo.name|getShort=6,'...'}" class="panel" data-selected="true"  data-menu="msgmenu" style="padding:0;">
        <header>
            <div id="header-buttons">
                <a href="javascript:history.go(-1);">
                    <div id="back" class="header-menu-link" data-back="false">
                    </div>
                </a>

                <div id="messageLink" class="header-menu-link"><a href="{:U('w3g/Index/msgbox')}"><i class="num"></i></a></div>
        <div id="menuLink" class="header-menu-link"></div>
            </div>
            <h1 class="hasback">
                {$groupinfo.name|getShort=6,'...'}
            </h1>
        </header>
<div class="mainWeiba">
  <!-- <div class="path"> <a href="{:U('w3g/Group/index')}">群组</a><i>></i><a href="{:U('w3g/Group/detail', 'gid='.$gid )}">{$groupinfo.name}</a><i>></i><a href="{:U('w3g/Group/topic', 'gid='.$gid)}"><span class="text-required">帖子</span></a></div> -->
  <div class="postDetail">
    <div class="pc_title">{$topic.title}</div>
    <div class="pc_info">
      <dl>
        <dt><a href="{:U('w3g/Index/profile',array('uid'=>$topic['uid']))}" ><img with="35" height="35" src="{$topic.uid|getUserFace}"></a></dt>
        <dd>
          <span class="floor">楼主</span>
          <php>if ($ismember) { </php>
              <span class="right mr1em">
                <php>if($mid == $topic['uid'] || $isadmin){</php>
                <a href="javascript:delThread({$gid},{$topic['id']});">删除</a> <i class="vline">|</i>
                <php>}</php>
                <a href="{:U('w3g/Group/reply_reply',array('tid'=>$topic['id'],'gid'=>$gid, 'qid'=>$topic['pid']))}">引用</a>
              </span>
          <php>}</php>
          <div class="name"><a href="{:U('w3g/Index/profile','uid='.$topic['uid'])}">{$topic['uid']|getUserName}</a></div>
          <div class="info">
            <p class="right"> 
             <span class="ml5"><img class="icons" height="14" src="{:APPS_URL}/w3g/_static/images/ico_llan.png">{$topic['viewcount']|default=0}</span> <span class="ml5"><img class="icons" height="14" src="{:APPS_URL}/w3g/_static/images/ico_pl.png">{$topic['replycount']|default=0}</span> </p>
            <p class="date">{$topic['addtime']|friendlyDate}</p>
          </div>
        </dd>
      </dl>
    </div>
    <div class="pc_text content_imgs" id="detail_content_img" >{$topic.content|html_entity_decode=###, ENT_QUOTES, 'UTF-8'|parse_html}</div>
    <div class="pc_reply">
      <div class="comment_lists">
        <volist name="postlist.data" id="vo" key="k">
          <dl class="comment_list clearfix">
            <dt><a href="{:U('w3g/Index/profile',array('uid'=>$vo['uid']))}" ><img with="35" height="35" src="{$vo.uid|getUserFace}"></a></dt>
            <dd> <span class="floor">
              <php>echo ($postlist['nowPage']-1)*20 + $k;</php>
              楼</span>
              <p class="cont"> <a href="{:U('w3g/Index/profile',array('uid'=>$vo['uid']))}" >{$vo.uid|getUserName}</a> </p>
              <p class="info"><span class="time">{$vo.ctime|friendlyDate}</span></p>
              <div class="cc content_imgs reply_content_img">
                <php>if($vo['quote']){ $qcontent = getPost($vo['quote']);</php>
                <div id="quotes" class="quote"> <em>原帖由
                  <a href="{:U('w3g/Index/profile',array('uid'=>$qcontent[uid]))}" >@{$qcontent[uid]|getUserName}</a>
                  于{$qcontent['ctime']|friendlyDate}发表</em> {$qcontent['content']|html_entity_decode=###, ENT_QUOTES, 'UTF-8'|parse_html} </div>
                <php>}</php>
                {$vo['content']|html_entity_decode=###, ENT_QUOTES, 'UTF-8'|parse_html} </div>
                
              <php>if ($ismember) { </php>
              <p class="info"> <span class="right">
                <php>if($mid == $vo['uid'] || $isadmin){</php>
                <a href="javascript:delPost({$gid},{$vo['id']});">删除</a> <i class="vline">|</i>
                <php>}</php>
                <a href="{:U('w3g/Group/reply_reply',array('tid'=>$topic['id'],'gid'=>$gid, 'qid'=>$vo['id']))}">引用</a> </span> </p>
              <php>}</php>
              
            </dd>
          </dl>
        </volist>
      </div>
      <div class="mini-page">{$postlist.waphtml}</div>
      
      <!-- 回复 begin-->
      <php>if($topic['lock'] == 0 && $mid){</php>
      <form method="post" action="{:U('w3g/Group/topic_reply')}" id="replyForm" enctype="multipart/form-data">
        <div class="input" model-node="comment_textarea">
          <dl>
            <dt><a href="{:U('w3g/Index/profile',array('uid'=>$GLOBALS['ts']['user']['uid']))}"><img width="35" height="35" src="{$GLOBALS['ts']['user']['avatar_middle']}"></a></dt>
            <dd> <a name="reply_place"></a>
              <div class="input_before1" model-node="mini_editor">
                <input type="hidden" name="gid" value="{$gid}">
                <input type="hidden" name="tid" value="{$tid}">
                <textarea class="s-textarea" id="comment_inputor" name="content" event-node="mini_editor_textarea" hidefocus="true" model-args='t=comment'></textarea>
             
              <div class="action clearfix">
                <div><a type="submit" class="btn right" onClick="replySubmit();"  value="发表" id="send_reply" >发表</a></div>
                <div class="acts">

                  <a event-node="insert_face" class="face-block" href="javascript:;" title="表情"><img height="28" class="icons" src="{:APPS_URL}/w3g/_static/images/ico_face.png"></a>

                   <a href="javascript:void(0);" class="image-block"><img height="28" class="icons" src="{:APPS_URL}/w3g/_static/images/ico_photo.png">
						    <input type="file" name="image_ids" inputname='image' onchange="core.plugInit('uploadFile',this,'','image')" urlquery='attach_type=feed_image&upload_type=image&thumb=1&width=100&height=100&cut=1' hidefocus="true">
						    </a><span class="f10">可多次上传图片</span>
                </div>
                <div class="pb">
                  <ul class="img_list" id="img_list">
                  </ul>
                </div>
                
                <div class="clear"></div>
                <div model-node="faceDiv"></div>
              </div> </div>
            </dd>
          </dl>
        </div>
      </form>
      <php>} elseif($mid) {</php>
      <div class="li mt10 clearfix">
        <form method="post" action="{:U('group/Topic/post')}" id="replyForm">
          <div>
            <div style="padding:0 0 10px 0; color:#555; text-align:center;">本贴已锁定暂时不能回复</div>
          </div>
        </form>
    </div>
      <php>} else {</php>
      <div class="li mt10 clearfix">
        <form method="post" action="{:U('group/Topic/post')}" id="replyForm">
          <div>
            <div style="padding:0 0 10px 0; color:#555; text-align:center;">登录后才能回复，点击<a href="{:U('w3g/Public/login')}">进入登录</a></div>
          </div>
        </form>
      </div>
        <php>}</php>        
        <!-- 回复 end--> 
  </div>
</div>  
</div>
</div>
<script type="text/javascript">

// 过滤html，字串检测长度
function checkPostContent(content)
{
	content = content.replace(/&nbsp;/g, "");
	content = content.replace(/<br>/g, "");
	content = content.replace(/<p>/g, "");
	content = content.replace(/<\/p>/g, "");
	return getLength(content);
}
var has_submit = 0;
function replySubmit() {
	if(has_submit==1)
		return false;
	var content = $('#comment_inputor').val();
    content = removeHTMLTag(content);
	if(checkPostContent(content) < 10) {
		$.ui.showMask('回复内容不能小于10个字',true);
		return false;
	}else{
		has_submit = 1;
	    $("#replyForm").submit();
	}
}
	function delThread(gid, tid)   {
		if (confirm("删除后无法恢复！确认删除整个帖子？"))		{
			$.ajax({
				type: "POST",
				url: U('w3g/Group/del'),
				data:   "type=thread&gid="+gid+"&tid="+tid,
				success: function(msg){
					var msg = eval('('+msg+')');
					if(msg.flag!=1){
						$.ui.showMask(msg.msg, true);
					}else{
						$.ui.showMask(msg.msg, true);		
						setTimeout("location.href = '{:U('w3g/Group/topic', 'gid='.$gid)}'",1500);				
					}
				}
			});			
		}
	}
	function delPost(gid,pid)	{
		if (confirm("删除后无法恢复！确认删除该条回复？"))		{
			$.ajax({
				type: "POST",
				url: U('w3g/Group/del'),
				data:   "type=post&gid="+gid+"&tid="+pid,
				success: function(msg){
					var msg = eval('('+msg+')');
					if(msg.flag!=1){
						$.ui.showMask(msg.msg, true);
					}else{
						$.ui.showMask(msg.msg ,true);				
						setTimeout("location.href = location.href",1500);				
					}
				}
			});
		}
	}
</script> 

<!--大图相册的效果-->
<style type="text/css">
/*大图相册的效果*/
.device {
  display:none;position: absolute;top: 0px;left: 0px;width: 100%;height: 100%;background-color: #333;z-index: 9;
}
.device .showImg{position: relative;}
.device .showImg_t{height: 38px;line-height: 38px;text-align: center;background-color: #000;color: #fff;font-size: 14px;padding: 0 20px;}
.device .showImg_close{position: absolute;right: 20px;top: 10px; color: #fff;}
.device .swiper-container {
  width: 100%;
  padding-top: 32px;
}
.device .content-slide {
  padding: 20px;  color: #fff;
}
.device .title {
  font-size: 25px;  margin-bottom: 10px;
}
.device .pagination {
  position: absolute; left: 0;  text-align: center; top: 50px;  width: 100%;  z-index: 9;
}
.device .swiper-pagination-switch {
  display: inline-block;  width: 12px;  height: 12px; background: #ccc; margin: 0 3px;  cursor: pointer;}
.device .swiper-active-switch {
  background: #e21e1f;
}
</style>
<div class="device">
  <div class="showImg"> <a class="showImg_close" href="javascript:void(0)" onClick="closeBox()">关闭</a>
    <h1 class="showImg_t">图片浏览</h1>
    <div class="swiper-container">
      <div class="swiper-wrapper" id="content_img_list"> 
        <!--        <div class="swiper-slide">
            <img src="{$vo.img_url}" alt="{$vo.ad_name}" width="100%" height="198" />
          </div>--> 
        
      </div>
    </div>
    <div class="pagination"></div>
  </div>
</div>
<include file="../Public/footer" />